
#ifndef DATABASEADAPTER_H
#define DATABASEADAPTER_H

#include "Thread.h"
#include "Types.h"
#include "Infobus.h"
#include "EventScheme.h"
#include "Action.h"

class DatabaseAdapter : public Thread
{
public:
  static DatabaseAdapter * getInstance(E_SUBJECT subj = UNKNOWN);

  DatabaseAdapter(E_SUBJECT subj);
  virtual ~DatabaseAdapter();

  virtual void onMessage(infobus::types::Message * m) = 0;
  virtual void run() = 0;
  virtual void dispatch(const char * msg) = 0;

  virtual void setStatus(E_STATUS stat, infobus::types::Message * pMsg) = 0;
  virtual void execute(const char* pszSql) = 0;
  void setAliveBeats(bool bEnable);
  void setListener(class IListener * pListen);
  IListener* getListener() { return m_pListener; };

  const char* getSubjectText();
  const char* getSender();
protected:
  static const char* SubjectText(E_SUBJECT s);
  static E_SUBJECT SubjectEnum(const char* s);

protected:
  bool cnOpen;
  infobus::types::Message * pMsg;
  E_SUBJECT subject;
  char szSender[256];
  IListener * m_pListener;
  bool m_bAliveBeats;
  friend class infobus::types::Message;
private:
  static char m_szTmpSubj[256];
};





#endif

